var Mock = require('mockjs')
var data = Mock.mock({
  'cart|50': [
    {
      'id|+1': 1,
      img: '@image(100x200, @color(), @ctitle())',
      count: 1,
      price: '@integer(1, 100)',
      goodsName: '@ctitle(5)',
    },
  ],
})
module.exports = (app) => {
  app.get('/api/list', (req, res) => {
    const { page = 1, size = 5 } = req.query
    res.json({
      code: 0,
      msg: 'success',
      data: {
        total: data.cart.length,
        list: data.cart.slice((page - 1) * size, page * size),
      },
    })
  })
}
